package com.datang.litejvm.cmd;

import com.datang.litejvm.clz.Class;
import com.datang.litejvm.constant.ConstantPool;

public abstract class TwoOperandCmd extends ByteCodeCommand {
    int oprand1 = -1;
    int oprand2 = -1;


    public void setOprand1(int oprand1) {
        this.oprand1 = oprand1;
    }

    public void setOprand2(int oprand2) {
        this.oprand2 = oprand2;
    }

    public int getOprand1() {
        return oprand1;
    }

    public int getOprand2() {
        return oprand2;
    }

    public TwoOperandCmd(ConstantPool pool, String opCode) {
        super(pool, opCode);
    }

    public int getLength() {
        return 3;
    }

    /**
     * @author: 顶风少年
     * @Description: 获取方法在常量池中的位置
     * @date: 22:20 2022/6/16
     **/
    public short getIndex() {
        short index = (short) (oprand1 << 8 | oprand2);
        return index;
    }
}
